﻿using System.IO;

namespace Raven
{
    public class SpawnPoint : BaseGameEntity
    {
        private DisplayObject _displayObject;

        public SpawnPoint(Vector2 pos):base(EntityType.SpawnPoint)
        {
            _position = pos;
            CreateDisplayObject();
        }
        
        public SpawnPoint(BinaryReader reader):base(EntityType.SpawnPoint)
        {
            _position = new Vector2(new Fix(reader.ReadInt32()), new Fix(reader.ReadInt32()));
            CreateDisplayObject();
        }

        public override void Destroy()
        {
            _displayObject.Destroy();
            _displayObject = null;
        }

        public void CreateDisplayObject()
        {
            _displayObject = DisplayObjectFactory.CreateDisplayObject(this);
            _displayObject.Start();
        }
    }
}